{extend name="public:layout" /}
{block name="title"}规格管理{/block}
{block name="head"}{/block}
{block name="body"}
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="ibox">
        <div class="ibox-title">
            <ol class="breadcrumb">
                <li><i class="fa fa-hand-o-right"></i> 规格列表</li>
            </ol>
        </div>
        <div class="ibox-content">
            <div class="toolbar">
                <div class="pull-left">
                    <button class="btn btn-white" type="button"
                            onclick="updateOrder()">
                        <i class="fa fa-sort"></i>更新排序
                    </button>
                    <a class="btn btn-primary" href="{:url('add')}">
                        <i class="fa fa-plus"></i>&nbsp;添加规格
                    </a>
                </div>
                <div class="pull-right">
                    <form class="form-inline" method="post">
                        <div class="form-group">
                            <div class="input-group">
                                <input class="form-control" name="attr_name" type="text" value="{$query.attr_name}" placeholder="检索关键词">
                            </div>
                        </div>
                        <button type="submit" class="btn btn-info">
                            <i class="fa fa-search"></i> 搜索
                        </button>
                        <a class="btn btn-white" href="{:url('index')}">
                            <i class="fa fa-trash"></i> 清空
                        </a>
                    </form>
                </div>
                <div class="clearfix"></div>
            </div>
            <table class="table table-bordered">
                <thead>
                <tr>
                    <th width="50">#</th>
                    <th width="100">排序</th>
                    <th width="120">规格名</th>
                    <th width="100">展示形式</th>
                    <th>规格值</th>
                    <th width="120">操作</th>
                </tr>
                </thead>
                <tbody>
                {volist name="list" id="vo"}
                <tr>
                    <td>{$vo.attr_id}</td>
                    <td width="80"> <input type="text" class="form-control list_order"
                                name="list_order[{$vo.attr_id}]" value="{$vo['attr_sort']}"/>
                    </td>
                    <td>{$vo.attr_name}</td>
                    <td>{$vo['is_image']==1?'图片':'文本'}</td>
                    <td>{$vo.itemList}</td>
                    <td>
                        <a href="{:url('edit',['attr_id'=>$vo['attr_id']])}">编辑</a>
                        <a href="javascript:;" onclick="doAction(this);"
                           data-msg="确认删除吗？" data-url="{:url('del')}" data-params="attr_id={$vo.attr_id}">删除</a>
                    </td>
                </tr>
                {/volist}
                </tbody>
            </table>
            <div class="page-bar">{$list->render()}</div>
            <div class="clearfix"></div>
        </div>
    </div>
</div>
{/block}
{block name="script"}
<script type="text/javascript">
    //更新排序
    function updateOrder() {
        if ($(".list_order").length > 0) {
            var data = $(".list_order").serialize();
            var url = "{:url('updateOrder')}";
            getAjax(url, data, function (data) {
                layer.msg(data.msg, {icon: 1, time: 800}, function () {
                    rePage();
                });
            });
        }
    }
</script>
{/block}